package com.user.repositories;

import com.user.model.vo.QueryServerInfoVo;

public class OtherProvider {

    public String getServerInfoListByPage(QueryServerInfoVo queryServerInfoVo) {

        StringBuilder sql = new StringBuilder(200);

        sql.append("select " +
                " ts.id, ts.ip, ts.mery, ts.disk, ts.daik, ts.address, " +
                " tscz.id as serverCZId, tscz.money, tscz.star_time as starTime, tscz.end_time as endTime, tscz.user_id " +
                " from t_server_info as ts LEFT JOIN t_server_chuzu as tscz ON ts.id = tscz.server_id ");
        sql.append(" where 1=1 ");

        if (null != queryServerInfoVo.getDaik()) {
            sql.append(" and ts.daik = " + queryServerInfoVo.getDaik());
        }
        if (null != queryServerInfoVo.getDisk()) {
            sql.append(" and ts.daik = " + queryServerInfoVo.getDisk());
        }
        if (null != queryServerInfoVo.getMery()) {
            sql.append(" and ts.mery = " + queryServerInfoVo.getMery());
        }
        sql.append(" and tscz.state= 'N' and ts.deleted = '1' and tscz.deleted = '1' ");
        sql.append(" limit " + queryServerInfoVo.getPageIndex() * queryServerInfoVo.getPageSize() + "," + queryServerInfoVo.getPageSize());

        System.out.println(sql.toString());
        return sql.toString();
    }

    public String getServerInfoListCount(QueryServerInfoVo queryServerInfoVo) {

        StringBuilder sql = new StringBuilder(200);

        sql.append("select count(1) from t_server_info as ts LEFT JOIN t_server_chuzu as tscz ON ts.id = tscz.server_id");
        sql.append(" where 1=1 ");

        if (null != queryServerInfoVo.getDaik()) {
            sql.append(" and ts.daik = " + queryServerInfoVo.getDaik());
        }
        if (null != queryServerInfoVo.getDisk()) {
            sql.append(" and ts.daik = " + queryServerInfoVo.getDisk());
        }
        if (null != queryServerInfoVo.getMery()) {
            sql.append(" and ts.mery = " + queryServerInfoVo.getMery());
        }
        sql.append(" and tscz.state= 'N' and ts.deleted ='1' and tscz.deleted = '1' ");
        System.out.println(sql.toString());
        return sql.toString();
    }


}
